package com.inplaceedit.client.ui.note;

import java.util.Date;

import com.google.gwt.core.client.GWT;
import com.google.gwt.editor.client.LeafValueEditor;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Focusable;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.datepicker.client.DateBox;
import com.core.gwt.ui.client.IsFocusable;

public class NoteEditorView extends Composite implements NoteEditor,
		IsFocusable {

	interface Binder extends UiBinder<Widget, NoteEditorView> {
	}

	private static Binder uiBinder = GWT.create(Binder.class);

	@UiField
	DateBox time;
	@UiField
	TextArea text;

	public NoteEditorView() {
		initWidget(uiBinder.createAndBindUi(this));
		time.setFormat(new DateBox.DefaultFormat(DateTimeFormat
				.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_SHORT)));
	}

	@Override
	public Focusable asFocusable() {
		return text;
	}

	@Override
	public LeafValueEditor<String> getTextEditor() {
		return text.asEditor();
	}

	@Override
	public LeafValueEditor<Date> getTimeEditor() {
		return time.asEditor();
	}

}
